import 'dart:collection';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter2/progress/progress.dart';
import 'package:flutter2/textview/textview.dart';

import 'box/constrained/constrained.dart';
import 'box/decorated/decorated.dart';
import 'box/padding/padding.dart';
import 'button/button.dart';
import 'container/container.dart';
import 'edittext/edittext.dart';
import 'form/form.dart';
import 'imageview/imageview.dart';
import 'layout/center/center.dart';
import 'layout/colunm/colunm.dart';
import 'layout/flex/flex.dart';
import 'layout/position/position.dart';
import 'layout/row/row.dart';
import 'layout/wrap/wrap.dart';
import 'list/scroll/scrollbar.dart';
import 'swich/swich.dart';

void main() {
  runApp(_MyApp());
}

class _MyApp extends StatelessWidget {
  final Map<String, WidgetBuilder> _routers = new LinkedHashMap();

  void _initRouters() {
    _routers.clear();
    _routers['ScrollbarApp'] = (context) => ScrollbarApp();
    _routers['ContainerApp'] = (context) => ContainerApp();
    _routers['DecoratedApp'] = (context) => DecoratedApp();
    _routers['ConstrainedApp'] = (context) => ConstrainedApp();
    _routers['PaddingApp'] = (context) => PaddingApp();
    _routers['CenterApp'] = (context) => CenterApp();
    _routers['PositionApp'] = (context) => PositionApp();
    _routers['WrapApp'] = (context) => WrapApp();
    _routers['FlexApp'] = (context) => FlexApp();
    _routers['ColumnApp'] = (context) => ColumnApp();
    _routers['RowApp'] = (context) => RowApp();
    _routers['ProgressApp'] = (context) => ProgressApp();
    _routers['FormApp'] = (context) => FormApp();
    _routers['EditTextApp'] = (context) => EditTextApp();
    _routers['SwichApp'] = (context) => SwichApp();
    _routers['ImageViewApp'] = (context) => ImageViewApp();
    _routers['ButtonApp'] = (context) => ButtonApp();
    _routers['TextViewApp'] = (context) => TextViewApp();
  }

  @override
  Widget build(BuildContext context) {
    _initRouters();
    return MaterialApp(
      title: 'main',
      theme: ThemeData(primaryColor: Colors.blue),
      routes: _routers,
      home: Scaffold(
          appBar: AppBar(
            title: Text('flutter2'),
          ),
          body: ListView.builder(
            itemBuilder: (context, index) {
              var routerName = _routers.keys.toList()[index];
              return RaisedButton(
                child: Text(routerName),
                onPressed: () {
                  Navigator.pushNamed(context, routerName);
                },
              );
            },
            itemCount: _routers.length,
          )),
    );
  }
}
